//
//  EarnTableViewCell.m
//  LPTClient
//
//  Created by mac on 2018/12/6.
//  Copyright © 2018年 zhaodd. All rights reserved.
//

#import "EarnTableViewCell.h"

@interface EarnTableViewCell ()

@property (weak, nonatomic) IBOutlet UILabel *zhenjinLabel;
@property (weak, nonatomic) IBOutlet UILabel *dateLabel;
@property (weak, nonatomic) IBOutlet UILabel *amoutLabel;

@end

@implementation EarnTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(void)refreshWithDic:(NSDictionary *)dic
{
    if ([dic valueForKey:@"flow_type"]) {
        
        //流水
        if ([dic[@"flow_type"] isEqualToString:@"cash"]) {
            self.zhenjinLabel.text = @"提现";
        }else if ([dic[@"flow_type"] isEqualToString:@"invite"]){
            self.zhenjinLabel.text = @"邀请奖金";
        }else if ([dic[@"flow_type"] isEqualToString:@"income"]){
            self.zhenjinLabel.text = @"收益";
        }
        
        self.dateLabel.text = dic[@"created_at"];
        self.amoutLabel.text = dic[@"change"];
        
        if ([dic[@"change"] floatValue] < 0) {
            self.amoutLabel.textColor = [UIColor greenColor];
        }else{
            self.amoutLabel.textColor = [UIColor redColor];
            self.amoutLabel.text = [NSString stringWithFormat:@"+%@",dic[@"change"]];
        }
        
    }else if ([dic valueForKey:@"actual_amount"]){
        
        //提现记录
        self.amoutLabel.textColor = [UIColor redColor];
        self.zhenjinLabel.text = dic[@"bank_card"][@"bank"];
        self.dateLabel.text = dic[@"created_at"];
        self.amoutLabel.text = [NSString stringWithFormat:@"-%@",dic[@"amount"]];
        
    }else{
        
        //收益明细
        self.zhenjinLabel.text = [dic[@"commodity_type"] isEqualToString:@"text_visit"]?@"诊金":@"药品订单";
        self.amoutLabel.text = [NSString stringWithFormat:@"+%@",dic[@"amount"]];
        self.dateLabel.text = dic[@"created_at"];
        
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
